var  express = require('express');
var  login = require('./admin/login');

var  router = express.Router();


// 中间件
router.use(function (req,res,next) {
    if (req.url =='/login' || req.url == '/login/dologin'){
        next();
    }else {
        if (req.session.userinfo){

            req.app.locals['userinfo'] = req.session.userinfo;
            next();
        } else {
            res.redirect('/admin/login');
        }
    }
});





// 分发路由
router.use('/login',login);

module.exports  = router;
